<include file="../header" />
<body>
<div class="wraper">
	<div class="load">
		<img class="load-bee" src="/assets/base/repair/images/load-bee.png"/>
	</div>
    <div class="top">
        <p>
			<a href="/Repairnew/RepairnewUserOrder/userOrderList/repairId/{BEESCRM:$repairId}" class="iconfont icon-zuo fl-left"></a>
			<span class="fl-left">订单详情</span>
			<a href="/Repairnew/RepairnewUserOrder/userOrderList/repairId/{BEESCRM:$repairId}" class="iconfont text-right  icon-shouye fl-right"></a>
		</p>
    </div>
    <p class="title">报修编号</p>
    <p class="list" style="margin-bottom: 10px;">{BEESCRM:$info.order_sn}</p>

    <!--非补录订单-->
    <if condition="$info['order_type'] neq 5">
		<!--已下单-->
		<div class="dialog clearfix">
	        <span class="right-big"></span>
	        <span class="right-middle"></span>
	        <p>
	        	<span class="circle gray"></span>已下单<span class="time fl-right">{BEESCRM:$info.create_time|date='Y-m-d H:i',###}</span>
	        </p>
	        <p><span>报修人：</span> {BEESCRM:$info['real_name']|mb_substr=0,1,'utf8'}某某</p>
	        <p><span>联系电话：</span> <a href="tel://{BEESCRM:$info.mobile}">{BEESCRM:$info.mobile}</a></p>
	        <p><span>报修区域：</span> {BEESCRM:$info.community_name}</p>
	        <p><span>报修地址：</span> {BEESCRM:$info.building_name}{BEESCRM:$info.room_name} {BEESCRM:$info.detail_address}</p>
	        <p><span>报修内容：</span> {BEESCRM:$info.content}</p>
	        <P><span>报修项目：</span>{BEESCRM:$info.project_name}　　{BEESCRM:$info.project_child_name}</P>

	        <if condition="$info['order_img']">
		        <volist name="info['order_img']" id="vo">
		        	<if condition="$vo['type'] eq 0"><img class="picture fl-left" src="{BEESCRM:$vo.url}"/></if>
		        </volist>
		    </if>
	    </div>
		<!--已下单 end-->

		<!--已取消--->
		<if condition="$info['status'] eq 0">
			<div class="dialog clearfix">
				<span class="left-big"></span>
				<span class="left-middle"></span>
				<p>
					<span class="circle orange"></span>
					已取消
					<span class="time fl-right">{BEESCRM:$info['cancel_time']|date='Y-m-d H:i',###}</span>
				</p>
				<p><span>取消说明：</span>{BEESCRM:$info['memo']}</p>
			</div>
		</if>
		<!--已取消结束-->
	</if>
	<!--非补录判断结束-->

	<!--已转为非日常订单 在已接单前就转-->
	<if condition="$info['order_type_id'] neq 0 and $info['status'] lt 3">
		<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle orange"></span>
				已转为非日常订单
				<span class="time fl-right">{BEESCRM:$info['nodaily_time']|date='Y-m-d H:i',###}</span>
			</p>
			<p><span>备注:</span>{BEESCRM:$info.nodaily_remark}</p>
		</div>
	</if>
	<!--已转为非日常订单 end-->

	<!--已接单-->
	<if condition="$info['status'] egt 3 and $info['status'] elt 12 and $info['order_type'] neq 5">
		<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle orange"></span>
				已接单
				<span class="time fl-right">{BEESCRM:$info['confirm_time']|date='Y-m-d H:i',###}</span>
			</p>
			<p><span>受理人：</span> <if condition="$info['repairman_info']['real_name']">{BEESCRM:$info['repairman_info']['real_name']|mb_substr=0,1,'utf8'}师傅</if></p>
			<p><span>受理人电话：</span> <if condition="$info['repairman_info']['mobile'] eq 0">暂无<else/><a href="tel://{BEESCRM:$info['repairman_info']['mobile']}">{BEESCRM:$info['repairman_info']['mobile']}</a></if></p>
			<p><span>工号：</span> {BEESCRM:$info['repairman_info']['number']}</p>
			<p><span>处理说明：</span> {BEESCRM:$info['send_remark']}</p>
		</div>
	</if>
	<!--已接单 end -->

	<!--已转为非日常订单 在已接单后面转-->
	<if condition="$info['order_type_id'] neq 0 and $info['status'] egt 3">
		<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle orange"></span>
				已转为非日常订单
				<span class="time fl-right">{BEESCRM:$info['nodaily_time']|date='Y-m-d H:i',###}</span>
			</p>
		</div>
	</if>
	<!--已转为非日常订单 end-->

	<!--已维修-->
    <if condition="($info['status'] egt 5 and $info['status'] lt 10) or $info['status'] eq 12">
    	<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle green"></span>
				已维修
				<span class="time fl-right">{BEESCRM:$info['finish_time']|date='Y-m-d H:i',###}</span>
			</p>
			<p><span>完工操作:</span>
				<if condition="$info['repairman_info']">
					{BEESCRM:$info['repairman_info']['real_name']} &nbsp;&nbsp;
					<span>工号：</span>{BEESCRM:$info['repairman_info']['number']}
				</if>
			</p>
			<p><span>完工说明:</span>{BEESCRM:$info['finish_remark']}</p>
		</div>
    </if>
	<!--已维修 end-->

	<!--评价-->
	<if condition="$info['status'] eq 5">
		<div class="dialog clearfix">
			<span class="right-big"></span>
			<span class="right-middle"></span>
			<p>
				<span class="circle green"></span>
				待评价
			</p>
			<p class="form-box">
				<textarea class="textarea" placeholder="维修很辛苦，赶紧给个四星好评吧~" id="comment"></textarea>
			</p>
			<p class="stars-list">星级
				<span class="iconfont icon-xingxing star gray-star quality js_xing_comment"></span>
				<span class="iconfont icon-xingxing star gray-star quality js_xing_comment"></span>
				<span class="iconfont icon-xingxing star gray-star quality js_xing_comment"></span>
				<span class="iconfont icon-xingxing star gray-star quality js_xing_comment"></span>
				<span id="set_message" style="color:red;"></span>
				<a href="javascript:void(0)" class="submit" id="submit" style="background-color: green;padding: 8px;margin-top: 15px;color: #fff">提交评价</a>
			</p>
		</div>
	</if>
	<!--评价 end-->
	<!--已评价-->
	<if condition="($info['status'] eq 7 or $info['status'] eq 12) and $info['order_type_id'] eq 0">
		<div class="dialog clearfix">
			<span class="right-big"></span>
			<span class="right-middle"></span>
			<p>
				<span class="circle green"></span>
				已评价
				<span class="time fl-right">{BEESCRM:$info['comment_time']|date='Y-m-d H:i',###}</span>
			</p>
			<p><span>用户评价：</span> {BEESCRM:$info['comment']}</p>

			<p class="stars-list">星级
				<for start="0" end="$info['star']">
					<span class="iconfont icon-xingxing star quality"></span>
				</for>
				<for start="0" end="4-$info['star']">
					<span class="iconfont icon-xingxing star gray-star quality"></span>
				</for>
			</p>

		</div>
	</if>
	<!--已评价 end-->

	<!--待转派-->
	<if condition="$info['status'] eq 10">
		<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle orange"></span>
				待转派
				<span class="time fl-right">{BEESCRM:$info['change_apply_time']|date='Y-m-d H:i',###}</span>
			</p>
			<p><span>转派说明：</span>{BEESCRM:$info['change_remark']}</p>
		</div>
	</if>
	<!--待转派结束-->

	<!--已转派-->
	<if condition="$info['status'] eq 11">
		<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle orange"></span>
				已转派
				<span class="time fl-right">{BEESCRM:$info['change_apply_time']|date='Y-m-d H:i',###}</span>
			</p>
			<p><span>转派说明：</span>{BEESCRM:$info['change_remark']}</p>
			<p><span>查看：</span><a href="javascript:;" data-old_order_id="{BEESCRM:$info['order_id']}" class="js_new_order">查看新订单</a></p>
		</div>
	</if>
	<!--已转派结束-->

	<!--已返修-->
	<if condition="$info['status'] eq 12">
		<div class="dialog clearfix">
			<span class="left-big"></span>
			<span class="left-middle"></span>
			<p>
				<span class="circle orange"></span>
				已返修
				<span class="time fl-right"><a href="javascript:;" class="js_new_order" data-old_order_id="{BEESCRM:$info['order_id']}">查看新订单</a></span>
			</p>
		</div>
	</if>
	<!--已返修结束-->
</div>

<include file="../commonJS" />
<script type="text/javascript" src="/assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bower_components/upload/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/assets/bower_components/upload/jquery.fileupload.js"></script>
<script type="text/javascript" src="/assets/bower_components/upload/jquery.iframe-transport.js"></script>
<script src="/assets/base/repair/js/fastclick.min.js"></script>
<script>
	$(function(){
		//点击灰色星星
		$(document).on('click','.js_xing_comment.gray-star',function () {
			$(this).prevAll().removeClass('gray-star');
			$(this).removeClass('gray-star');
			//提示信息
			setMessage();
		});

		//点击黄色星星
		$(document).on('click','.js_xing_comment',function () {
			$(this).nextAll().addClass('gray-star');
			setMessage();
		});

		function setMessage(){
			var star_length = $('.quality:not(.gray-star)').length;
			if(star_length == 1){
				$('#set_message').text('童鞋，维修人员很辛苦，忍心给差评吗？');
			}else if(star_length == 2){
				$('#set_message').text('一般般');
			}else if(star_length == 3){
				$('#set_message').text('比较满意！');
			}else if(star_length == 4){
				$('#set_message').text('维修的很完美！');
			}
		}

		//点击查看新订单
		$(document).on('click','.js_new_order',function () {
			var old_order_id = $(this).data('old_order_id');
			var repairId = "{BEESCRM:$repairId}";
			$.ajax({
				url : "/Repairnew/RepairnewUserOrder/ajaxGetOrderInfo/repairId/{BEESCRM:$repairId}",
				type : 'POST',
				data : {'old_order_id' : old_order_id},
				dataType : 'JSON',
				success : function (data) {
					if(data.status == 'S'){
						var order_id = data.data.order_id;
						location.href="/Repairnew/RepairnewUserOrder/userOrderDetail/repairId/"+repairId+"/order_id/" + order_id;
					}else{
						$.alert('error',data.message);
					}
				}
			});
		});

		//提交评价
		$(document).on('click','#submit',function(){

			if($('.quality:not(.gray-star)').length <= 0) {
				$.alert('error','请完成所有评价，再提交~');
				return false;
			}
			var comment = $.trim($('#comment').val());
			if($('.quality:not(.gray-star)').length == 1 || $('.quality:not(.gray-star)').length == 4){
				if(comment == ''){
					$.alert('error','请填写评论内容');
					return false;
				}
			}
			$.ajax({
				type:'post',
				url:"/Repairnew/repairnewUserOrder/ajaxCommentOrder/repairId/{BEESCRM:$repairId}",
				dataType:'json',
				data:{
					'order_id':"{BEESCRM:$info.order_id}",
					'comment':comment,
					'star':$('.quality:not(.gray-star)').length
				},

				success:function(data){
					if(data.status=='S'){
						$.alert('success',data.message);
                        reload();                    }else{
						$.alert('error',data.message);
					}
				},
				error:function(){
					$.alert('error','网络错误，请稍后再试');
				}
			});
		});
    });

	//这个是调用微信图片浏览器的函数
	function imagePreview(curSrc,srcList) {
		//这个检测是否参数为空
		if(!curSrc || !srcList || srcList.length == 0) {
			return;
		}
		//这个使用了微信浏览器提供的JsAPI 调用微信图片浏览器
		WeixinJSBridge.invoke('imagePreview', {
			'current' : curSrc,
			'urls' : srcList
		});
	};

	(function($){
		//下面是获取当前页面所有的img的src 转成数组 并且 转换成json格式
		var aa=[];
		var i=0;
		var src=[];
		var json=null;
		aa=$('img');
		for (i=0;i<aa.length;i++){
			src[i]=aa[i].src;    //把所有的src存到数组里
		}
		var srcList=arrayToJson(src); //转换成json并赋值给srcList
		//下面是点击图片的时候获取当前第几个图片并且启用咱们做的调用微信图片浏览器的函数
		$('img').click(function(){
			var index = $('img').index(this);
			imagePreview(src[index],src);
		});

	})(jQuery);

	//下面这个函数用来转换数组到json格式
	function arrayToJson(o) {
		var r = [];
		if (typeof o == "string") return "\"" + o.replace(/([\'\"\\])/g, "\\$1").replace(/(\n)/g, "\\n").replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\"";
		if (typeof o == "object") {
			if (!o.sort) {
				for (var i in o)
					r.push(i + ":" + arrayToJson(o[i]));
				if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)) {
					r.push("toString:" + o.toString.toString());
				}
				r = "{" + r.join() + "}";
			} else {
				for (var i = 0; i < o.length; i++) {
					r.push(arrayToJson(o[i]));
				}
				r = "[" + r.join() + "]";
			}
			return r;
		}
		return o.toString();
	}

    //刷洗页面
    function reload() {
        window.location.href=window.location.href+"?RAND="+parseInt(100*Math.random());
    }
</script>
</body>

</html>
